﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Book_of_Shadow_Script
{
    //从码表文件中获得码表
    class CodePageFixed
    {
        int[] ctb;
        char[] btc;
        public int[] ToByte{get{return ctb;}}
        public CodePageFixed()
        {
            ctb=new int[0x10000];
            btc = new char[0x10000];
        }
        public void Import(String fName)
        {
            StreamReader sr = new StreamReader(fName);
            Int32 line = 0;
            TextFormat_CodeTable tc = new TextFormat_CodeTable();
            string str;
            while (!sr.EndOfStream)
            {
                line++;
                str = sr.ReadLine();
                str = str.TrimStart(null);
                if (str.Length == 0) continue;
                tc.FromString(str);
                ctb[tc.Character]=tc.Code;
                btc[tc.Code] = tc.Character;
            }
            sr.Close();
        }

        public char[] ToChar { get { return btc; } }
    }
}
